package com.mh.controller;

import com.mh.common.R;
import com.mh.pojo.AppointmentInfo;
import com.mh.service.AppointmentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Date:2023/4/13
 * author:zmh
 * description: 医生界面相关接口
 **/

@RestController
@Slf4j
@RequestMapping("/doctorPages")
@CrossOrigin
public class DoctorPageController {

    @Autowired
    private AppointmentInfoService appointmentInfoService;

    /**
     * 医生界面-获取所有预约信息
     * @return 返回所有预约信息的列表
     */
    @GetMapping
    public R<List<AppointmentInfo>> getAllAppointmentInfo(){
        List<AppointmentInfo> list = appointmentInfoService.getAllDoctorPage();
        return R.success(list);
    }

    /**
     * 修改预约信息状态
     * @param status 0为"待开始"、1为"接诊中"、2为“已完成”、3为“已错过”
     * @return 返回执行修改的结果
     */
    @PutMapping
    public R<String> modifyAppointmentStatus(String uid,String status){
        log.info("接收到的uid为:{},修改状态为:{}",uid,status);
        String s = appointmentInfoService.modifyAppointmentStatus(uid, status);
        return R.success(s);
    }


}
